package com.zmy.xcx.project.controller;

import com.zmy.xcx.project.common.convention.result.Result;
import com.zmy.xcx.project.common.convention.result.Results;
import com.zmy.xcx.project.dao.entity.Patient;
import com.zmy.xcx.project.service.PatientService;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;

/**
 * 病人控制层
 */
@RestController
@RequiredArgsConstructor
public class PatientController {

    private final PatientService patientService;

    /**
     * 新增病人
     * @param patient
     * @return
     */
    @PostMapping("/patients")
    public Result<Void> createPatient(@RequestBody Patient patient){
        patientService.createPatient(patient);
        return Results.success();
    }

    /**
     * 根据病人id获取病人信息
     * @param id
     * @return Patient
     */
    @GetMapping("/patients/{id}")
    public Result<Patient> getPatient(@PathVariable("id") String id){
        return Results.success(patientService.getPatient(id));
    }
}
